<template>
  <el-card shadow="never">
    <e-table
      ref="eTable"
      @getList="handleGetList"
      :tableData="tableData"
      :columns="columns"
      :loading="loading"
      :total="total"
    >
      <el-table-column label="处方号" slot="prescript_no" align="center">
        <template slot-scope="scope">
          <el-button type="text" @click="handleDetail(scope.row)">{{ scope.row.prescript_no }}</el-button>
        </template>
      </el-table-column>
      <el-table-column label="特殊门诊处方" slot="clinic_spec_flag" align="center">
        <template slot-scope="scope">{{ scope.row.clinic_spec_flag === '0' ? '否' : '是' }}</template>
      </el-table-column>
    </e-table>
  </el-card>
</template>

<script>
import { getOverLimitPrescription } from '@/api/reports'
export default {
  data() {
    return {
      total: 1,
      loading: false,
      tableData: [],
      columns: [
        { slot: 'prescript_no' },
        {
          label: '医生姓名',
          prop: 'his_doctor_name'
        },
        {
          label: '科室名称',
          prop: 'his_dept_name'
        },
        {
          label: '患者姓名',
          prop: 'patient_name'
        },
        {
          label: '病历号',
          prop: 'med_record_no'
        },
        {
          label: '诊断名称',
          prop: 'diag_name'
        },
        {
          label: '处方时间',
          prop: 'prescript_time'
        },
        {
          label: '药品信息',
          prop: 'drug_info',
          tooltip: true
        },
        {
          label: '处方金额',
          prop: 'prescript_cost'
        },
        { slot: 'clinic_spec_flag' }
      ],
      queryParam: {
        pageSize: 10,
        pageNo: 1
      }
    }
  },
  methods: {
    //columns 动态删减，根据form传递过来的数据
    async handleGetList(param = {}) {
      this.loading = true
      this.queryParam = Object.assign(this.queryParam, param)
      const res = await getOverLimitPrescription(this.queryParam)
      if (res && res.data.records.length > 0) {
        const {
          state,
          data: { records, total }
        } = res
        this.tableData = records
        this.total = total
      } else {
        this.tableData = []
        this.total = 1
      }
      this.loading = false
    },
    handleDetail(row) {
      this.$router.push({
        name: 'report7Detail',
        params: { handleRow: row }
      })
    }
  }
}
</script>
